import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class CoreH5Service extends BaseService<any> {
  private readonly logger = new Logger(CoreH5Service.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * getH5
   * 对应 PHP: CoreH5Service_core::getH5()
   * 逻辑类型: undefined - undefined
   */
  async getH5(site_id: number) {
    // 基于PHP真实逻辑: getH5
    // PHP原文: $info = (new CoreConfigService())->getConfig($site_id, ConfigKeyDict::H5)['value'] ?? [];         if(empty($info))         {             $info = [    ...
const info = this.coreConfigService.getConfig(site_id, ConfigKeyDict.H5).value || [];
        if(!info))
        {
            const info = [
                is_open: 1
            ];
  }

  /**
   * mapKeyChange
   * 对应 PHP: CoreH5Service_core::mapKeyChange()
   * 逻辑类型: undefined - undefined
   */
  async mapKeyChange(map_key: string) {
    // 基于PHP真实逻辑: mapKeyChange
    // PHP原文: $compile_path = project_path(). 'uni-app' . DIRECTORY_SEPARATOR;         $this->mergeManifestJson($compile_path, [             "h5" => [              ...
const compile_path = project_path() + 'uni-app' . DIRECTORY_SEPARATOR;
        this.mergeManifestJson(compile_path, [
            h5: [
                sdkConfigs: [
                    maps: [
                        qqmap: [
                            key: map_key
                        ]
                    ]
                ]
            ],
            "app-plus" => [
                distribute: [
                    sdkConfigs: [
                        maps: [
                            tencent: [
                                key: map_key
                            ]
                        ]
                    ]
                ]
            )
        );
  }
  }
}
